﻿using T4UtilityBelt.Serializers;
using T4UtilityBelt.UxDesigns;
using T4UtilityBelt.UxDesigns.Controls;

namespace T4UtilityBelt.DataDesigns
{
    public class BoolProperty : EntityProperty
    {
        private const string RequiredType = "bool";
        private const string DefaultType = "bool?";

        public BoolProperty()
            : base(DefaultType)
        {
        }

        public BoolProperty(string name)
            : base(DefaultType, name)
        {
        }

        public BoolProperty(string name, bool required)
            : base(required ? RequiredType : DefaultType, name, required)
        {
        }

        public override UxDesigns.Control CreateControl()
        {
            return new BoolControl(this);
        }

        [XIgnore()]
        public override bool IsPropertyTypeSpecified
        {
            get
            {
                return DefaultType != PropertyType;
            }
        }
    }
}